<?php

use App\Http\Controllers\Admin\OrderController;
use App\Http\Controllers\Api\CartsController;
use App\Http\Controllers\Api\CollectController;
use App\Http\Controllers\Api\CommentsController;
use App\Http\Controllers\Api\LoginController;
use App\Http\Controllers\Api\OrderController as ApiOrderController;
use App\Http\Controllers\Api\PayController;
use App\Http\Controllers\Api\ProductsController;
use App\Http\Controllers\Api\SystemController;
use App\Http\Controllers\Api\UsersController;
use App\Models\Users;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

//Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
//    return $request->user();
//});

Route::middleware([\App\Http\Middleware\Api\LoginCheck::class])->group(function () {



    //忘记密码
    Route::post('forgetPassword', [\App\Http\Controllers\Api\LoginController::class, 'forgetPassword']);
    //购物车
    Route::apiResource('carts', CartsController::class);


    //用戶詳情
    Route::get('getuser',[UsersController::class,'index']);
    //修改用户信息
    Route::put('updateuser',[UsersController::class,'update']);
    //修改用户密碼
    Route::put('updatepassword',[UsersController::class,'updatePassword']);
    //评论
    Route::post('comments',[CommentsController::class,'store']);
    //我的收藏
    Route::get('getcollect',[CollectController::class,'getCollect']);
    //收藏取消
    Route::get('collect',[CollectController::class,'index']);
    //获取通知
    Route::get('notice',[\App\Http\Controllers\Api\NoticeController::class,'getNotice']);
    //已讀通知
    Route::put('notice',[\App\Http\Controllers\Api\NoticeController::class,'readNotice']);
    //刪除通知
    Route::delete('notice',[\App\Http\Controllers\Api\NoticeController::class,'deleteNotice']);
    //我的优惠券
    Route::get('coupon',[\App\Http\Controllers\Api\CouponController::class,'getCoupon']);
    //购买产品
    Route::post('createorder', [\App\Http\Controllers\Api\OrderController::class, 'createOrder']);
    //查看全部預約訂單
    Route::get('getreservationall', [\App\Http\Controllers\Api\OrderController::class, 'getReservationAll']);
    //確認收貨
    Route::get('affirmOrder',[ApiOrderController::class,'affirmOrder']);
    //兌換優惠券
    Route::get('exchangeCoupon',[UsersController::class,'exchangeCoupon']);
    //積分記錄
    Route::get('getintegral',[UsersController::class,'recordIntegral']);
    //产品详情
    Route::get('getproduct/{id}', [ProductsController::class, 'show']);
    //获取二维码
    Route::get('qr',[UsersController::class,'qr']);
    //订单二维码
    Route::get('orderqr',[UsersController::class,'orderQr']);

    //钱包充值
    Route::post('burse',[PayController::class,'burse']);
    //产品列表
Route::get('getproduct', [ProductsController::class, 'index']);
//支付
    Route::get('pay',[PayController::class,'index']);
//推荐商品
Route::get('recommend', [ProductsController::class, 'recommend']);
//商品詳情
Route::get('orderinfo',[\App\Http\Controllers\Api\OrderController::class,'getOrderInfo']);
//获取全部订单
    Route::get('getorderall', [\App\Http\Controllers\Api\OrderController::class, 'getOrderAll']);
    //註銷
    Route::any('cancel',[UsersController::class,'delete']);
});
//获取钱包充值下限
Route::get('getmoney',[SystemController::class,'getMoney']);
/***************************************************无需验证 */
//登陆
Route::any('login', [\App\Http\Controllers\Api\LoginController::class, 'Login']);

Route::any('facebookLogin',[LoginController::class,'appleFaceBookLogin']);

Route::any('appleLogin',[LoginController::class,'appleLogin']);
//預約訂單
Route::post('reservation', [\App\Http\Controllers\Api\OrderController::class, 'createReservation']);




//注册
Route::any('register', [\App\Http\Controllers\Api\LoginController::class, 'register']);
//支付回调
Route::any('notify',[PayController::class,'notify']);
//用户协议
Route::get('agreement',[SystemController::class,'agreement']);

//获取分类
Route::get('category',[\App\Http\Controllers\Api\CategoryController::class,'getCateGory']);
//发送短信验证码
Route::any('sendMobileCode', [\App\Http\Controllers\Api\SendController::class, 'sendMobileCode']);

//所有优惠券
Route::get('couponall',[\App\Http\Controllers\Api\CouponController::class,'couponAll']);
//圖片上傳
Route::post('upload', [\App\Http\Controllers\Api\UploadController::class, 'store']);
//获取等级
Route::get('grade',[UsersController::class,'grade']);
//关于我们
Route::get('about',[SystemController::class,'getAbout']);
//常见问题
Route::get('question',[SystemController::class,'getQuestion']);
//条款
Route::get('clause',[SystemController::class,'getClause']);
//忘記密碼
Route::post('forgetPassword',[LoginController::class,'forgetPassword']);
